package part10_代理模式_调用目标对象.p02_动态代理;

/**
 * @ClassName: Client
 * @Author: AllenSun
 * @Date: 2020/3/3 23:40
 */
public class Client {
    public static void main(String[] args) {
        //创建目标对象
        ITeacherDao target= new TeacherDao();
        //给目标对象，创建代理对象
        ITeacherDao proxyInstance= (ITeacherDao) new ProxyFactory(target).getProxyInstance();

        //proxyInstance=class com.sun.proxy.$Proxy0 是内存中动态生成了代理对象
        System.out.println("proxyInstance="+proxyInstance.getClass());

        //通过代理对象，调用目标对象的方法
        proxyInstance.teach();
        proxyInstance.sayHello("老王");
    }
}
